//
//  TDTipsViewController.h
//  TaduFramework
//
//  Created by Xu Nicholas on 11-8-1.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#if TARGET_OS_IPHONE

#import <UIKit/UIKit.h>

#else

#endif

#import <QuartzCore/QuartzCore.h>
#import "ModalViewController.h"

@class TDTipsInfo;
@protocol ModalViewDelegate;

@protocol TipsViewDelegate
@optional
- (void)animationStated;
- (void)animationShownFinished:(BOOL)isFinished;
- (void)animationHiddenFinished:(BOOL)isFinished;

@end

#ifndef TIPS_TIME_OUT
#define TIPS_TIME_OUT   1.5f
#endif

#if TARGET_OS_IPHONE

@interface TDTipsViewController : UIViewController <ModalViewDelegate> {
//    UIImage * backgroundImage;
    //tips background queue
    dispatch_queue_t _tips_queue;
    NSOperationQueue *_tips_operation_queue;
}

@property (nonatomic, retain) TDTipsInfo * info;
@property (nonatomic, retain) ModalViewController * modal;
@property (nonatomic, retain) IBOutlet UIView * subView;
@property (nonatomic, retain) IBOutlet UITextView * textViewForTips;
/*
 右上角的取消按钮
 */
@property (nonatomic, retain) IBOutlet UIButton *cancelButtonOnCorner;
/*
 取消按钮，保留未用
 */
@property (nonatomic, retain) IBOutlet UIButton * rightButton;
/*
 确认按钮，保留未用
 */
@property (nonatomic, retain) IBOutlet UIButton * leftButton;

@property (nonatomic, retain) IBOutlet UILabel * tipsLabel;
@property (nonatomic, retain) IBOutlet UILabel * tipsLabelt;
@property (nonatomic, retain) IBOutlet UIView * panel;
@property (nonatomic, retain) NSString * tipsString;
@property (nonatomic, retain) NSString * tipsStringt;
@property (nonatomic, assign) CGRect subframe;
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView * activity;
@property (nonatomic) UIEdgeInsets edgeInsetsForTipsLabel;
@property (nonatomic, retain) UIImage * backgroundImage;
@property (nonatomic, assign) id delegate;

#pragma mark - configurate main window which be shown on.
+ (void)setMainWindow:(UIView *)mainWindow;

#pragma mark - factory methods to show message rapidly.
+ (void)showTipsMessage:(NSString *)message duration:(NSTimeInterval) durationTime;
+ (void)showTipsMessage:(NSString *)message withTitle:(NSString *)title duration:(NSTimeInterval) durationTime;
+ (void)showTipsMessage:(NSString *)message;

#pragma mark - show view methods

- (void)showViewWithTipsInfo:(TDTipsInfo*)info;
- (void)hide;

- (void)showView;
- (void)showViewUntilSeconds:(NSTimeInterval) timeInterval;
- (void)showViewUntilSecondsNumber:(NSNumber*) timeInterval;

#pragma mark - event methods
- (IBAction)onClick_rightButton:(id)sender;
- (IBAction)onClick_leftButton:(id)sender;
- (IBAction)onClickButton:(UIButton *)button;

@end

/*
 取消提示框 block 类型声明
 */
typedef void(^TIPS_CANCEL_OPERATION)();

#pragma mark - TDTipsInfo 提示信息类（包含对弹出提示的所有配置信息）

@interface TDTipsInfo : NSObject

@property (nonatomic, retain) NSString * title;
@property (nonatomic, retain) NSString * message;
@property (nonatomic) CGFloat timeInterval;
@property (nonatomic) BOOL hidden;
@property (nonatomic, copy) TIPS_CANCEL_OPERATION cancelOperation;
@property (nonatomic) BOOL updateView;


+ (TDTipsInfo*)infoWithMessage:(NSString *)message TimeInterval:(CGFloat)timeInterval HiddenActivity:(BOOL)hidden;
+ (TDTipsInfo*)infoWithMessage:(NSString *)message TimeInterval:(CGFloat)timeInterval HiddenActivity:(BOOL)hidden NeedUpdateView:(BOOL)needUpdate;
+ (TDTipsInfo*)infoWithMessage:(NSString *)message TimeInterval:(CGFloat)timeInterval HiddenActivity:(BOOL)hidden UsingCancelBlock:(TIPS_CANCEL_OPERATION) cancelOperation;

+ (TDTipsInfo*)infoWithTitle:(NSString *)title Message:(NSString *)message TimeInterval:(CGFloat)timeInterval HiddenActivity:(BOOL)hidden;

@end

#endif
